import 'package:flutter_download_plugin/utils/video/hls_segment.dart';
import 'package:flutter_download_plugin/utils/video/video_utils.dart';
import 'package:flutter_hls_parser/flutter_hls_parser.dart';

class VideoPreviewInfo {
  ///最终下载的url，主文件时是文件的url，媒体文件时是媒体的下载url
  String url;
  int width;
  int height;
  int bitrate;

  ///单位秒
  int duration;

  ///m3u8文件时的分片信息
  final List<HlsSegment> segments;
  int segmentsIndex;

  ///m3u8的文件信息
  String m3u8Info;

  ///有些m3u8可能会吧视频、音频、头文件等额外信息分离可能会有多个媒体链接，
  final List<Uri?> mediaPlaylistUrls;

  VideoPreviewInfo({
    required this.url,
    this.width = 0,
    this.height = 0,
    this.bitrate = 0,
    this.duration = 0,
    this.segmentsIndex = 0,
    this.segments = const [],
    this.m3u8Info = "",
    this.mediaPlaylistUrls = const [],
  });

  String getDurationTime() {
    return VideoUtils.formatDuration(duration.toDouble());
  }
}
